<?php

namespace App\Http\Controllers\Api\Home;

use App\Http\Controllers\Api\Controller;
use App\Models\Banner;
use App\Models\Help;
use App\Models\Order;
use App\Transformers\BannerTransformer;
use App\Transformers\HelpTransformer;
use App\Transformers\OrderTransformer;
use Illuminate\Http\Request;


class SearchController extends Controller
{
    //查看帮助
    public function help(Help $help){

        $query=$help->query();
        $res=$query->paginate(10);

        return $this->response->paginator($res,new HelpTransformer());
    }

    //首页轮播图
    public function banner(Banner $banner){
        $banners = $banner->all()->where('status','=',1);
        return $this->response->collection($banners,new BannerTransformer());
    }

    //最近成交
    public function chengjiao(Order $order){

        $query=$order->query()->where('order_type','=',1)->
                where('order_payment','=',1)->orderBy('id','desc');

        $res=$query->paginate(20);

        return $this->response->paginator($res,new OrderTransformer());
    }
}
